package com.yh.correct.service.impl;

import java.util.Map;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yh.correct.dao.IMentalityMapper;
import com.yh.correct.model.Page;
import com.yh.correct.service.IMentalityService;
/**
 * 心理矫正登记服务层实现类
 * 
 * @author 王鹏程 
 * @date 2017.03.23
 * @time 10:40    
 */
@Service
public class MentalityServiceImpl implements IMentalityService {

	/**
	 * 日志记录
	 */
	private static Logger logger = LogManager.getLogger(MentalityServiceImpl.class);
	/**
	 * 注入心理矫正登记数据访问层接口
	 */
	@Autowired
	private IMentalityMapper mentalityMapper;
	/**
	 * 模糊查询心理矫正登记
	 * 
	 * @param condition
	 * @return
	 */
	@Override
	public Page getLikeMentality(Map<String, Object> condition) {
		Page page=new Page();
		page.setTotalNum( mentalityMapper.getLikeMentalityCount(condition));
		int pageSize = Integer.parseInt(String.valueOf(condition.get("pageSize")));
		page.setPageSize(pageSize);
		int curPageNum = Integer.parseInt(String.valueOf(condition.get("pageNum")));
		page.setCurPageNum(curPageNum);
		page.setTotalPage(page.getTotalNum()/pageSize+(page.getTotalNum()%pageSize==0?0:1));
		page.setResult(mentalityMapper.getLikeMentality(condition));
		logger.debug("模糊查询心理矫正登记!");
		return page;
	}

}
